package mini.statement;

import java.util.LinkedList;
import java.util.List;

import mini.Env;
import mini.Proc;


// added for 2c
public class DefineStatement extends Statement {

    private String name;
    private Proc proc;

    public DefineStatement(String id, Proc process) {
        name = id;
        proc = process;
    }

    public void eval(List<Env> listOfEnvs, LinkedList var) {
        if( listOfEnvs != null && listOfEnvs.size() > 0 ) {
        	Env env = listOfEnvs.get(listOfEnvs.size()-1);
        	env.addToFunctiontable(name, proc);
        } else {
        	System.err.println( "Internal error in Definition Statement of " + name + "=" + proc );
        }
    }
}